package cn.tedu.charging.cost.controller;

import cn.tedu.charging.common.pojo.jsonResult.JsonResult;
import cn.tedu.charging.common.pojo.jsonResult.param.ChargingProcessParam;
import cn.tedu.charging.common.pojo.jsonResult.vo.ChargingProcessVO;
import cn.tedu.charging.cost.service.CostService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("cost")
@Api(tags = "cost")

public class CostController {
    @Autowired
    private CostService costService;

    @ApiOperation("计算价格")
    @PostMapping("calculate")
    public JsonResult<ChargingProcessVO> process(@RequestBody ChargingProcessParam chargingProcessParam){
        log.debug("开始计算价格,入参:{}",chargingProcessParam);
        ChargingProcessVO chargingProcessVO=costService.calculate(chargingProcessParam);
        log.debug("计算价格结束,出参:{}",chargingProcessVO);

        return JsonResult.ok(chargingProcessVO,"计算价格成功");
    }

}
